//"javascript:gopage('urll','caidd','focc');"
//	javascript:gopage('list.jsp','<%=CategoryUtils.JJ%>','');
function gopage(ull,caidd,focc){
	SetCookie("pid",caidd);
	SetCookie("focusid",focc);
	SetCookie("listret",window.location.href);
	window.location.href=ull;
}
//var paramm="&typeId="+catalogid+"&contentId="+contentId;
//objd.href="javascript:goPlay('"+contentId+"','"+catalogid+"','');";
function goPlay(conTidd,caidd,paramm){
	SetCookie("conTid", conTidd);
	SetCookie("pid", caidd);
	window.location.href=relativePathPrefix+"industry/play/play_transfer.jsp?contentid="+conTidd+"&categoryId="+caidd+"&contentType=1";
}

//获得ip
var retUrl="";
var server_ip="";
function psip(urll){
	var ipp="";
	try {
		urll=urll.substring(urll.indexOf("//"));
		ipp=urll.substring(2,urll.indexOf(":"));
	} catch (e) {
	}
	return ipp;
}

//retUrl=window.location.href;
//server_ip=psip(retUrl);


//图片地址分割
function pspics(urll){
	var picc=[];
	try {
		if(urll.indexOf(",")!=-1){
			picc=urll.split(",");
		}else{
			picc.push(urll);
		}
	} catch (e) {
	}
	return picc;
}
//去掉html标签 和转义字符 //适合动态生成的html
function cutdesc(str){
	try {
		var str1 =str.replace(/<[^>]+>/g,"");
		return str1.replace(/&amp;/g,'&');
	} catch (e) {
	}
}
//分割desc
function psdesc(str){
	var arr=[];
	try {
		if(str.indexOf("|")!=-1){
			arr.concat(str.split("|"));
		}else{
			arr.push(str);
		}
	} catch (e) {
	}
	return arr;
}

//停止小窗口播放
function stopMovv(){
	  try {
	    	if($("mv_box")){
		  		if(window.mv_box){
		  			window.mv_box.mp.stop();
		  		}else if($("mv_box").contentWindow){
		  			$("mv_box").contentWindow.mp.stop();
		  		}
		  	}
		  
		} catch (e) {
		}
}
function getListt(idd,countt,f_cp_cpridd,funn){
		var paramJson={};
		paramJson.id =idd;
		paramJson.startindex = 0;
		paramJson.count = countt;
		paramJson.f_cp_cprid = f_cp_cpridd;
		paramJson.ispublic = 1;//都用1
		getCatalogContentListById(relativePathPrefix,paramJson,funn);
    	}
function getfll(catalogidd,countt,funn){
	var paramJson={};
	paramJson.f_catalog_id=catalogidd;
	paramJson.pageNo=0;
	paramJson.pageSize=countt;
	paramJson.f_is_public=1;
	catalog_catalogInfoListByparamJson(relativePathPrefix,paramJson,funn);
}
//iPanel.defaultalinkBgColor = "#81ac40";//设置文字链接焦点颜色 
//iPanel.defaultFocusColor = "#81ac40";//设置图片链接焦点颜色 
//iPanel.focusWidth = "5";//焦点框宽度

/*去边框*/

try{
	var STB = navigator.appName;
	if(STB == "Ranger" || STB == "EIS iPanel"){//机顶盒浏览器区分 华为 创维
		iPanel.focusWidth = "-1";//焦点框宽度
	}else if(STB == "ztebw" || STB == "Fhbw2.0"){//中兴 烽火
		iPanel.focusWidth = "0";//焦点框宽度
	}else{
		iPanel.focusWidth = "0";//焦点框宽度
	}
}catch(e){}

var jkurl="http://10.255.247.100:7780/huafang_transfer/service/";
//var jkurl="http://115.238.31.212:8081/huafang_transfer/service/";
var imgTransfer="http://220.191.197.150:7772/proxy/?u=";


var showTimer = -1;	
var bottomTimer;

document.onirkeypress = keyevent;
document.onkeypress = keyevent;
	
var backurl="";
var preurl="";
var nexturl="";

function setUrl(url,_preurl,_nexturl)
{
	if(url!=''&&url!=null)
		backurl=url;
	if(_preurl!=''&&_preurl!=null)
		preurl=_preurl;
	if(_nexturl!=''&&_nexturl!=null)
		nexturl=_nexturl;
}
var 	pageTag="";	//pageTag="index";
function keyevent(evt)
{
	evt=evt?evt:window.event;
	var keycode=evt.keyCode?evt.keyCode:evt.which;
  switch (keycode)
    {
//	    case 768: //0x300
//			goUtility();
//			break;
//		case 38: 
//			volUp();
//			break;
//		case 40: 
//			volDown();
//			break;
       case 48:
    	   if(videoframe){
          		videoframe.window.mp.pause();
          }
			break;
       case 768:
    	   if(videoframe){
           		videoframe.window.keypress(keycode);
           }else{
   				goUtility();
           }
			break;
		case 259:
            if(videoframe){
            	videoframe.window.keypress(keycode);
            }else{
            	 volumeUp();
//    			volUp();
            }
			break;
        case 260:
            if(videoframe){
            	videoframe.window.keypress(keycode)
            }else{
            	  volumeDown();
//      			volDown();
            }
			break;
		case 261:
            setMuteFlag();
			break;
        case 8:
				if(backurl==""){
					history.back();
				}else{
					document.location.href=backurl;
				}
				break;
        default:
            break;
    }
	  try {
			if($("mv_box")){
				if(window.mv_box){
					window.mv_box.checkMvKey(keycode);
				}else if($("mv_box").contentWindow){
					$("mv_box").contentWindow.checkMvKey(keycode);
				}
			}
		} catch (e) {}
}


function volumeUp()
{
	clearTimeout(showTimer);
	showTimer = -1;
	
	var muteFlag = mp.getMuteFlag();
	if(muteFlag == 1)
	{
		mp.setMuteFlag(0);
	}
	
	volume = mp.getVolume(); 
	
	if(volume >= 100)
	{
		volume = 100;
    }
    else
    {
        volume += 5;
	}
	
	mp.setVolume(volume);  
	if (mp.getNativeUIFlag() == 0 || mp.getAudioVolumeUIFlag() == 0)
	{
		clearTimeout(bottomTimer);
		bottomTimer = "";
		genVolumeTable(volume);
		bottomTimer = setTimeout("hideBottom();", 5000);
	}
	
}


function setMuteFlag()
{
	clearTimeout(showTimer);
	showTimer = -1;
	clearTimeout(bottomTimer);
	bottomTimer = ""; 
	var muteFlag = mp.getMuteFlag();
	if(muteFlag == 1)
	{
		mp.setMuteFlag(0);
		if (mp.getNativeUIFlag() == 0 || mp.getMuteUIFlag() == 0)
		{
			var offpath = rootPath+"/images/muteoff.gif";
			document.getElementById("bottomframe").innerHTML = '<table><tr><td><img border="0" src="'+offpath+'"></td></tr></table>';
			bottomTimer = setTimeout("hideBottom();", 5000);
		}
	}
	else
	{
		mp.setMuteFlag(1);
		if (mp.getNativeUIFlag() == 0 || mp.getMuteUIFlag() == 0)
		{
			var onpath = rootPath+"/images/muteon.gif";
			document.getElementById("bottomframe").innerHTML = '<table><tr><td><img border="0" src="'+onpath+'"></td></tr></table>';
			//bottomTimer = setTimeout("hideBottom();", 5000);
		}
	}      
}


function volumeDown()
{
	clearTimeout(showTimer);
	showTimer = "";
	
	var muteFlag = mp.getMuteFlag();
	if(muteFlag == 1)
	{
		mp.setMuteFlag(0);
	}
	
	volume = mp.getVolume();
			
	if(volume <= 0)
	{
		volume = 0;    
	}
	else
	{
		volume -= 5;
	}
	
	mp.setVolume(volume);  
	
	if (mp.getNativeUIFlag() == 0 || mp.getAudioVolumeUIFlag() == 0)
	{
		clearTimeout(bottomTimer);
		bottomTimer = "";
		genVolumeTable(volume);
		bottomTimer = setTimeout("hideBottom();", 5000);
	}
}

function genVolumeTable(volume)
{
	var tableDef = '<table width="490" border="0" cellpadding="0" cellspacing="0"><tr>';
	volume = volume / 5;

	for (i = 0; i < 40; i++)
	{
		if (i % 2 == 0)
		{
			tableDef += '<td width="10px" height="40px" bgcolor="transparent"></td>';
		}
		else
		{
			if ( i / 2 < volume)
			{
				tableDef += '<td width="10px" height="40px" bgcolor="#00ff00"></td>';
			}
			else
			{
				tableDef += '<td width="10px" height="40px" bgcolor="#cccccc"></td>';
			}
		}
	}
	var volpath = rootPath+"/images/volume.gif";
	tableDef += '<td width="10px"></td><td width="36px"><img src="'+volpath+'"></td><td width="40px" style="color:white;font-size:28">' + volume + '</td>';
	
	tableDef += '</tr></table>'; 
	document.getElementById("bottomframe").innerHTML = tableDef;    	
}

function hideBottom()
{
	document.getElementById("bottomframe").innerHTML = "";
}


/*日期*/
var datespace="-";
function show_date(did,wid,tid,delay){
	itfunc(did,wid,tid);
	setInterval(
			function (){
				itfunc(did,wid,tid);
			}
			, delay*1000);
}
var tq_date;
function itfunc(did,wid,tid){
	var date=new Date();
	var mm=(date.getMonth()+1);
	if(mm<10){
		mm="0"+mm;
	}
	var dd=date.getDate();
	if(dd<10){
		dd="0"+dd;
	}
	var datestr=""+date.getFullYear()+datespace+mm+datespace+dd;
	tq_date=""+date.getFullYear()+"-"+mm+"-"+dd;
	var arr1=new Array("星期天","星期一","星期二","星期三","星期四","星期五","星期六");
	var week=arr1[date.getDay()];
	var h=date.getHours();
	if(h<10){
		h="0"+h;
	}
	var mi=date.getMinutes();
	if(mi<10){
		mi="0"+mi;
	}
	var ss=date.getSeconds();
	if(ss<10){
		ss="0"+ss;
	}
	var time=h+":"+mi;

	if(""!=did&&document.getElementById(did)){
		document.getElementById(did).innerHTML="<span>"+datestr+"</span>";
	}
	if(""!=wid&&document.getElementById(wid)){
		document.getElementById(wid).innerHTML="<span>"+week+"</span>";
	}
	if(""!=tid&&document.getElementById(tid)){
		document.getElementById(tid).innerHTML="<span>"+time+"</span>";
	}
}
//获得对象
function $(id) {
    if (document.getElementById(id)) {
        return document.getElementById(id);
    } else if (document.all) {
        return document.all[id];
    }else{
    	return null;
    }
}

/*	焦点框移动放大效果
*	id:	获取焦点的ID
*	pic: 焦点显示效果的图片
*	w: 宽度增加
*	h: 高度增加
*/
function onFoc(id, pic, w, h){
	var nowWidth = $(id).childNodes[0].width;
	var nowHeight = $(id).childNodes[0].height;
	var nowTop = $(id).style.top;
	var nowLeft = $(id).style.left;
	
	if(nowTop.indexOf("px")){
		nowTop = nowTop.substring(0,nowTop.length-2);
	}
	if(nowLeft.indexOf("px")){
		nowLeft = nowLeft.substring(0,nowLeft.length-2);
	}
	var picO=$(id).getElementsByTagName("img")[0];
	$(id).style.top = (parseInt(nowTop)-(parseInt(w)/2))+"px";
	$(id).style.left = (parseInt(nowLeft)-(parseInt(h)/2))+"px";
	picO.width = parseInt(nowWidth)+parseInt(w);
	picO.height = parseInt(nowHeight)+parseInt(h);
	picO.src=pic;
}

/*	焦点框移动放大效果
*	id:	获取焦点的ID
*	pic: 焦点显示效果的图片
*	w: 宽度减少
*	h: 高度减少
*/
function unFoc(id, pic, w, h){
	var nowWidth = $(id).childNodes[0].width;
	var nowHeight = $(id).childNodes[0].height;
	var nowTop = $(id).style.top;
	var nowLeft = $(id).style.left;
	
	if(nowTop.indexOf("px")){
		nowTop = nowTop.substring(0,nowTop.length-2);
	}
	if(nowLeft.indexOf("px")){
		nowLeft = nowLeft.substring(0,nowLeft.length-2);
	}
	var picO=$(id).getElementsByTagName("img")[0];
	picO.src=pic;
	$(id).style.top = (parseInt(nowTop)+(parseInt(w)/2))+"px";
	$(id).style.left = (parseInt(nowLeft)+(parseInt(h)/2))+"px";
	picO.width = parseInt(nowWidth)-parseInt(w);
	picO.height = parseInt(nowHeight)-parseInt(h);
}

/*
 * 设置聚焦效果
 */
function setFocPic(btnIddd,focIddd){
	if(document.getElementById(btnId)&&document.getElementById(focId)){
		var obj=document.getElementById(btnId);
		obj.foc=focId;
		obj.onfocus=function(){
			document.getElementById(this.foc).style.display="block";
		};
		obj.onblur=function(){
			document.getElementById(this.foc).style.display="none";
		};
	}
}
function setFocPicc(btnClasss,focClasss){
	if($c(btnClasss)&&$c(focClasss)){
		var obj=$c(btnClasss);
		obj.foc=$c(focClasss);
		obj.onfocus=function(){
			this.foc.style.display="block";
		};
		obj.onblur=function(){
			this.foc.style.display="none";
			try{
				var STB = navigator.appName;
				if(STB == "Ranger" || STB == "EIS iPanel"){//机顶盒浏览器区分 华为 创维
					iPanel.focusWidth = "-1";//焦点框宽度
				}else if(STB == "ztebw" || STB == "Fhbw2.0"){//中兴 烽火
					iPanel.focusWidth = "0";//焦点框宽度
				}else{
					iPanel.focusWidth = "0";//焦点框宽度
				}
			}catch(e){};
		};
	}
}
function $c(clas){
	if(document.getElementsByClassName(clas)){
		if(document.getElementsByClassName(clas).length==1){
			return document.getElementsByClassName(clas)[0];
		}else if(document.getElementsByClassName(clas).length>1){
			return document.getElementsByClassName(clas);
		}else{
			return null;
		}
	}else{
		return null;
	}
}

function $t(objj,tagNamee){
	if(objj&&objj.getElementsByTagName(tagNamee)){
		if(objj.getElementsByTagName(tagNamee).length==1){
			return objj.getElementsByTagName(tagNamee)[0];
		}else if(objj.getElementsByTagName(tagNamee).length>1){
			return objj.getElementsByTagName(tagNamee);
		}else{
			return null;
		}
	}else{
		return null;
	}
}
function getFcd(obj){
	  var objChild = [] ;
	  var objs = obj.getElementsByTagName('*');
	  for(var i=0,j=objs.length; i<j;++i){
	    if(objs[i].nodeType != 1){
//			alert(objs[i].nodeType);
			continue ;
	    }
	    var temp = objs[i].parentNode;
	    if(temp.nodeType == 1){
	      if(temp == obj){
	        objChild[objChild.length] = objs[i] ;
	      }
	    }else if(temp.parentNode == obj){
	      objChild[objChild.length] = objs[i] ;
	    }
	  }
	  return objChild ;
}

function testJson(jsonn){
	if(""!=jsonn&&"null"!=jsonn&&jsonn!=null){
		return jsonn;
	}
	return null;
}

function forPara(urll){
	if(urll.indexOf("?")!=-1){
		urll=urll+"&";
	}else{
		urll=urll+"?";
	}
	return urll;
}

String.prototype.trim=function(){
    return this.replace(/(^\s*)|(\s*$)/g, "");
 }
 String.prototype.ltrim=function(){
    return this.replace(/(^\s*)/g,"");
 }
 String.prototype.rtrim=function(){
    return this.replace(/(\s*$)/g,"");
 }
 
//经纬算距离(米)
// var FINAL = 6378.137;
// function getRadian(ddd){
//     return ddd*Math.PI/180.0 ;
// }   
// function getDistance(xx,yy,xxx,yyy){
//	 xx=parseFloat(xx);
//	 yy=parseFloat(yy);
//	 xxx=parseFloat(xxx);
//	 yyy=parseFloat(yyy);
//	  var a, b, d, sa2, sb2;
//	  yy = getRadian(yy);
//	  yyy = getRadian(yyy);
//      a = yy - yyy;
//      b = getRadian(xx - xxx);
//
//      sa2 = Math.sin(a / 2.0);
//      sb2 = Math.sin(b / 2.0);
//      d = 2   * FINAL
//              * Math.asin(Math.sqrt(sa2 * sa2 + Math.cos(yy)
//              * Math.cos(yyy) * sb2 * sb2));
//      d = Math.round(d * 1000.0); 
//      return d;
// }

